package cn.ywrby.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则处理数据工具
 */
public class RegularUtils {

    public static List<String> getApplyType(String regularStr){
        List<String> applyTypeList=new ArrayList<>();

        // 按指定模式在字符串查找
        String pattern = "\\[([\\u4e00-\\u9fa50-9]+)-([\\u4e00-\\u9fa50-9]+)\\]";

        // 创建 Pattern 对象
        Pattern r = Pattern.compile(pattern);

        // 创建 matcher 对象
        Matcher m = r.matcher(regularStr);
        if (m.find( )) {
            try {
                String type=m.group(1);
                String subType=m.group(2);
                applyTypeList.add(type);
                applyTypeList.add(subType);
            }catch (Exception e){
                e.printStackTrace();
            }
        } else {
            //System.out.println("NO MATCH");
            return null;
        }

        return applyTypeList;
    }


}
